// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package pica.core;

import java.util.Vector;

public final class f
{

    public f(byte byte0)
    {
        b = -1;
        d = 0;
        e = 0;
        f = 5;
        a = byte0;
        c = new Vector();
    }

    private Object[] a(String s, byte byte0, boolean flag)
    {
        Object aobj[] = {
            new Byte((byte)1), s, new Byte(byte0), new Boolean(flag), new Integer(0), new Integer(0)
        };
        c.addElement(((Object) (aobj)));
        return aobj;
    }

    public final void a(Object aobj[], String s, byte byte0)
        throws Exception
    {
        Object aobj1[] = null;
        int j = 0;
        int k = 0;
        if(c.size() == 0)
            b = 0;
        for(int l = 0; l < c.size(); l++)
        {
            Object aobj3[];
            if(((Byte)(aobj3 = (Object[])c.elementAt(l))[0]).byteValue() != 1)
                throw new Exception("\u8BE5\u5217\u8868\u5206\u7EC4\u7684\u6210\u5458\u8BA1\u6570\u51FA\u73B0\u9519\u8BEF\uFF01");
            if(((Byte)aobj3[0]).byteValue() != 1)
                continue;
            k = ((Integer)aobj3[4]).intValue();
            if(((String)aobj3[1]).equals(s) && ((Byte)aobj3[2]).byteValue() == byte0)
            {
                aobj1 = aobj3;
                j = l;
                break;
            }
            l += k;
        }

        if(aobj1 == null)
        {
            Object aobj2[] = a(s, byte0, true);
            aobj[3] = ((Object) (aobj2));
            c.addElement(((Object) (aobj)));
            if(((Byte)aobj[2]).byteValue() >= f)
                aobj2[5] = new Integer(((Integer)aobj2[5]).intValue() + 1);
            aobj2[4] = new Integer(((Integer)aobj2[4]).intValue() + 1);
            return;
        }
        if(k == 0)
        {
            aobj[3] = ((Object) (aobj1));
            c.addElement(((Object) (aobj)));
            aobj1[4] = new Integer(k + 1);
            return;
        }
        for(int i1 = j + 1; i1 < j + 1 + k; i1++)
        {
            Object aobj4[];
            if(((Byte)(aobj4 = (Object[])c.elementAt(i1))[2]).byteValue() < ((Byte)aobj[2]).byteValue())
            {
                aobj[3] = ((Object) (aobj1));
                c.insertElementAt(((Object) (aobj)), i1);
                aobj1[4] = new Integer(k + 1);
                if(((Byte)aobj[2]).byteValue() >= f)
                    aobj1[5] = new Integer(((Integer)aobj1[5]).intValue() + 1);
                return;
            }
        }

        aobj[3] = ((Object) (aobj1));
        c.insertElementAt(((Object) (aobj)), j + 1 + k);
        aobj1[4] = new Integer(k + 1);
        if(((Byte)aobj[2]).byteValue() >= f)
            aobj1[5] = new Integer(((Integer)aobj1[5]).intValue() + 1);
    }

    public final void a(Object aobj[], boolean flag)
    {
        if(flag)
        {
            for(int j = 0; j < c.size(); j++)
            {
                Object aobj1[];
                if(((Byte)(aobj1 = (Object[])c.elementAt(j))[2]).byteValue() < ((Byte)aobj[2]).byteValue())
                {
                    c.insertElementAt(((Object) (aobj)), j);
                    if(c.size() == 1)
                        b = 0;
                    return;
                }
            }

            c.addElement(((Object) (aobj)));
        } else
        {
            c.addElement(((Object) (aobj)));
        }
        if(c.size() == 1)
            b = 0;
    }

    public final void a(Object aobj[], int j)
    {
        c.insertElementAt(((Object) (aobj)), j);
        if(c.size() == 1)
            b = 0;
    }

    public final Object[] a(String s, byte byte0)
        throws Exception
    {
        boolean flag = false;
        for(int k = 0; k < c.size(); k++)
        {
            Object aobj[];
            if(((Byte)(aobj = (Object[])c.elementAt(k))[0]).byteValue() != 1)
                throw new Exception("\u8BE5\u5217\u8868\u5206\u7EC4\u7684\u6210\u5458\u8BA1\u6570\u51FA\u73B0\u9519\u8BEF\uFF01");
            if(((Byte)aobj[0]).byteValue() != 1)
                continue;
            int j = ((Integer)aobj[4]).intValue();
            if(((String)aobj[1]).equals(s) && ((Byte)aobj[2]).byteValue() == byte0)
                return aobj;
            k += j;
        }

        return null;
    }

    public final Object[] a(String s)
    {
        for(int j = 0; j < c.size(); j++)
        {
            Object aobj[];
            if(((Byte)(aobj = (Object[])c.elementAt(j))[0]).byteValue() == 2 && ((String)aobj[1]).equals(s))
                return aobj;
        }

        return null;
    }

    public final Object[] a(int j)
    {
        if(j < 0 || j >= c.size())
            return null;
        else
            return (Object[])c.elementAt(j);
    }

    public final Object[] b(String s)
    {
        for(int j = 0; j < c.size(); j++)
        {
            Object aobj[];
            if(((Byte)(aobj = (Object[])c.elementAt(j))[0]).byteValue() == 3 && ((String)aobj[1]).equals(s))
                return aobj;
        }

        return null;
    }

    public final Object[] a(String s, boolean flag)
        throws Exception
    {
        Object aobj[] = null;
        for(int j = 0; j < c.size(); j++)
        {
            Object aobj1[];
            if(((Byte)(aobj1 = (Object[])c.elementAt(j))[0]).byteValue() == 3)
                continue;
            if(((Byte)aobj1[0]).byteValue() == 1)
            {
                aobj = aobj1;
                continue;
            }
            if(((Byte)aobj1[0]).byteValue() != 2)
                continue;
            if(aobj == null)
                throw new Exception("\u8BE5\u5217\u8868\u9879\u6CA1\u6709\u5206\u7EC4:index=" + j);
            int k;
            if((k = ((Integer)aobj[4]).intValue()) <= 0)
                throw new Exception("\u5206\u7EC4\u8BA1\u6570\u9519\u8BEF\uFF1AgoupItemNum=" + aobj[4]);
            if(!((String)aobj1[1]).equals(s))
                continue;
            c.removeElement(((Object) (aobj1)));
            aobj[4] = new Integer(k - 1);
            if(((Byte)aobj1[2]).byteValue() >= f)
                aobj[5] = new Integer(((Integer)aobj[5]).intValue() - 1);
            if(flag && k - 1 == 0)
                c.removeElement(((Object) (aobj)));
            if(b >= c.size())
                b = c.size() - 1;
            return aobj1;
        }

        return null;
    }

    public final void b(int j)
    {
        if(((Byte)((Object[])c.elementAt(j))[0]).byteValue() == 3)
            c.removeElementAt(j);
        if(b >= c.size())
            b = c.size() - 1;
    }

    public final void a(Object obj)
    {
        c.removeElement(obj);
        if(b >= c.size())
            b = c.size() - 1;
    }

    public final void a()
    {
        c.removeAllElements();
        b = -1;
        d = 0;
    }

    public final int b()
    {
        return c.size();
    }

    public final Object[] c()
    {
        if(b < 0)
            return null;
        else
            return (Object[])c.elementAt(b);
    }

    public final void c(int j)
        throws Exception
    {
        Object aobj[];
        if(((Byte)(aobj = (Object[])c.elementAt(j))[0]).byteValue() != 1)
        {
            throw new Exception("\u8BE5\u9879\u4E0D\u662F\u4E00\u4E2A\u5206\u7EC4\uFF01");
        } else
        {
            aobj[3] = new Boolean(!((Boolean)aobj[3]).booleanValue());
            return;
        }
    }

    public final void a(boolean flag)
    {
        for(int j = 0; j < c.size(); j++)
        {
            Object aobj[];
            if(((Byte)(aobj = (Object[])c.elementAt(j))[0]).byteValue() == 1)
            {
                aobj[3] = new Boolean(flag);
                j += ((Integer)aobj[4]).intValue();
            }
        }

        b = 0;
        d = 0;
    }

    public final boolean d(int j)
    {
        Object aobj[];
        if(((Byte)(aobj = (Object[])c.elementAt(j))[0]).byteValue() == 1)
        {
            if(((Boolean)aobj[3]).booleanValue())
                j++;
            else
                j = j + ((Integer)aobj[4]).intValue() + 1;
        } else
        {
            j++;
        }
        return j >= c.size();
    }

    public final void d()
        throws Exception
    {
        if(b < 0)
        {
            throw new Exception("\u5149\u6807\u6CA1\u6709\u521D\u59CB\u5316\uFF1AselectIndex=" + b);
        } else
        {
            b = g(b);
            return;
        }
    }

    public final void e()
        throws Exception
    {
        if(b < 0)
        {
            throw new Exception("\u5149\u6807\u6CA1\u6709\u521D\u59CB\u5316\uFF1AselectIndex=" + b);
        } else
        {
            b = h(b);
            return;
        }
    }

    public final void e(int j)
    {
        for(int k = 0; k < j; k++)
        {
            int l = d;
            d = g(d);
            if(l > d)
                e--;
        }

    }

    public final void f(int j)
    {
        for(int k = 0; k < j; k++)
        {
            int l = d;
            d = h(d);
            if(l < d)
                e++;
        }

    }

    public final void f()
    {
        e = 0;
        d = 0;
    }

    public final void a(int j, int k)
    {
        e = g() - k;
        d = c(j, k - 1);
    }

    private int c(int j, int k)
    {
        for(int l = 0; l < k; l++)
            j = g(j);

        return j;
    }

    public final int b(int j, int k)
    {
        for(int l = 0; l < k; l++)
            j = h(j);

        return j;
    }

    public final int g(int j)
    {
        if(--j < 0)
            return 0;
        Object aobj[];
        if(((Byte)(aobj = (Object[])c.elementAt(j))[0]).byteValue() == 2)
        {
            int k = j - 1;
            do
            {
                if(k < 0)
                    break;
                Object aobj1[];
                if(((Byte)(aobj1 = (Object[])c.elementAt(k))[0]).byteValue() == 1)
                {
                    if(!((Boolean)aobj1[3]).booleanValue())
                        j = k;
                    break;
                }
                k--;
            } while(true);
        }
        return j;
    }

    public final int h(int j)
    {
        if(c.size() == 0)
            return 0;
        int k = j;
        Object aobj[];
        if(((Byte)(aobj = (Object[])c.elementAt(j))[0]).byteValue() == 1)
        {
            if(((Boolean)aobj[3]).booleanValue())
                j++;
            else
                j = j + ((Integer)aobj[4]).intValue() + 1;
        } else
        {
            j++;
        }
        if(j >= c.size())
            j = k;
        return j;
    }

    public final int g()
    {
        int j = 0;
        for(int k = 0; k < c.size(); k++)
        {
            Object aobj[];
            if(((Byte)(aobj = (Object[])c.elementAt(k))[0]).byteValue() == 3)
            {
                j++;
                continue;
            }
            if(((Byte)aobj[0]).byteValue() != 1)
                continue;
            j++;
            if(((Boolean)aobj[3]).booleanValue())
                j += ((Integer)aobj[4]).intValue();
            k += ((Integer)aobj[4]).intValue();
        }

        return j;
    }

    public final int h()
    {
        return d;
    }

    public final int i()
    {
        return e;
    }

    public byte a;
    private Vector c;
    public int b;
    private int d;
    private int e;
    private byte f;
}
